package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.NewsAuthDto;
import com.heima.model.wemedia.dtos.WmNewsDto;
import com.heima.model.wemedia.dtos.WmNewsPageReqDto;
import com.heima.wemedia.service.WmNewsService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/news")
@RequiredArgsConstructor
public class WmNewsController {

    private final WmNewsService wmNewsService;

    @PostMapping("/list")
    public ResponseResult findList(@RequestBody WmNewsPageReqDto wmNewsPageReqDto) {
        return wmNewsService.findList(wmNewsPageReqDto);
    }

    @PostMapping("/submit")
    public ResponseResult submitNews(@RequestBody WmNewsDto wmNewsDto){
       return wmNewsService.submitNews(wmNewsDto);
    }

    @GetMapping("/one/{id}")
    public ResponseResult getNewById(@PathVariable Integer id){
        return wmNewsService.getNewsById(id);
    }

    @GetMapping("/del_news/{id}")
    public ResponseResult deleteNewById(@PathVariable Integer id){
        return wmNewsService.deleteNewsById(id);
    }

    @PostMapping("/down_or_up")
    public ResponseResult downOrUp(@RequestBody WmNewsDto wmNewsDto){
        return wmNewsService.downOrUp(wmNewsDto);
    }

    /**
     * 自媒体文章人工审核
     * @param newsAuthDto
     * @return
     */
    @PostMapping("/list_vo")
    public ResponseResult listManualCheckNews(@RequestBody NewsAuthDto newsAuthDto){
         return wmNewsService.listManualCheckNews(newsAuthDto);
    }

    @GetMapping("/one_vo/{id}")
    public ResponseResult getNewsVoById(@PathVariable Integer id){
        return wmNewsService.getNewsVoById(id);
    }

    @PostMapping("/auth_fail")
    public ResponseResult wmNewsAuthFail(@RequestBody NewsAuthDto newsAuthDto){
        return wmNewsService.wmNewsAuthFailOrPass(newsAuthDto);
    }

    @PostMapping("/auth_pass")
    public ResponseResult wmNewsAuthPass(@RequestBody NewsAuthDto newsAuthDto){
        return wmNewsService.wmNewsAuthFailOrPass(newsAuthDto);
    }
}
